<?php
// Released under the GNU General Public License
if (defined( '_JEXEC' )){
$GLOBALS['database'] = $database = JFactory::getDBO();
}
global $database;

$country = $_GET['country'];

$zones_array = array();  
$database->setQuery("select zone_name from #__osc_zones where zone_country_id = '" . (int)$country . "' order by zone_name"); 
//$zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' order by zone_name");
$zones_values = $database->loadObjectList();

if(count($zones_values) > 0 ) {
$zoutput = "<select name='state'>";
 foreach($zones_values as $zone) {
 $zoutput .= '<option value="' . $zone->zone_name . '">' . $zone->zone_name . '</option>';
 }
 $zoutput .="</select>";
}else{
 $zoutput = "<input type='text' name='state'>";

}

//while ($zones_values = tep_db_fetch_array($zones_query)) {
//  $zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);
//}
header('Content-type: text/html; charset='.CHARSET);
/*
if ( tep_db_num_rows($zones_query) ) {
  echo tep_draw_pull_down_menu('state', $zones_array,'', '');
   if (tep_not_null(ENTRY_STATE_TEXT)) echo '&nbsp;<span class="inputRequirement">' . ENTRY_STATE_TEXT;
} else {
  echo tep_draw_input_field('state');
   if (tep_not_null(ENTRY_STATE_TEXT)) echo '&nbsp;<span class="inputRequirement">' . ENTRY_STATE_TEXT;
}
*/
echo $zoutput;
echo '&nbsp;<span class="inputRequirement">' . ENTRY_STATE_TEXT;

?>